﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kiosk.Utilities
{
    public class RssReaderCollection : List<RssReader>
    {
        int currentReader = 0;
        RssEntry currentEntry;


        /// <summary>
        /// Returns the next entry from the next feed in the collection
        /// </summary>
        public RssEntry GetNextEntry()
        {
            if (this.Count == 0)
            {
               return new RssEntry() { Headline = "No data available." };
            }
            
            if (currentReader == this.Count)
            {
                currentReader = 0;
            }


            RssEntry next = this[currentReader].GetNextEntry();
            currentEntry = next;
            currentReader++;


            return next;
        }

        public void RefreshAll()
        {
            foreach (RssReader r in this)
            {
                r.Refresh();
            }
        }


        public RssEntry CurrentEntry
        {
            get
            {
                return this.currentEntry;
            }
        }
    }
}
